3.1.8 \(\int (c+d x) \tanh ^2(e+f x) \, dx\) [8]

Optimal. Leaf size=40 \[ c x+\frac {d x^2}{2}+\frac {d \log (\cosh (e+f x))}{f^2}-\frac {(c+d x) \tanh (e+f x)}{f} \]

[Out]

c*x+1/2*d*x^2+d*ln(cosh(f*x+e))/f^2-(d*x+c)*tanh(f*x+e)/f

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 40, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, integrand size = 14, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3801, 3556} \begin {gather*} -\frac {(c+d x) \tanh (e+f x)}{f}+c x+\frac {d \log (\cosh (e+f x))}{f^2}+\frac {d x^2}{2} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(c + d*x)*Tanh[e + f*x]^2,x]

[Out]

c*x + (d*x^2)/2 + (d*Log[Cosh[e + f*x]])/f^2 - ((c + d*x)*Tanh[e + f*x])/f

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rubi steps

\begin {align*} \int (c+d x) \tanh ^2(e+f x) \, dx &=-\frac {(c+d x) \tanh (e+f x)}{f}+\frac {d \int \tanh (e+f x) \, dx}{f}+\int (c+d x) \, dx\\ &=c x+\frac {d x^2}{2}+\frac {d \log (\cosh (e+f x))}{f^2}-\frac {(c+d x) \tanh (e+f x)}{f}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.20, size = 77, normalized size = 1.92 \begin {gather*} \frac {c \tanh ^{-1}(\tanh (e+f x))}{f}+\frac {d \log (\cosh (e+f x))}{f^2}+\frac {d x \text {sech}(e) (f x \cosh (e)-2 \sinh (e))}{2 f}-\frac {d x \text {sech}(e) \text {sech}(e+f x) \sinh (f x)}{f}-\frac {c \tanh (e+f x)}{f} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(c + d*x)*Tanh[e + f*x]^2,x]

[Out]

(c*ArcTanh[Tanh[e + f*x]])/f + (d*Log[Cosh[e + f*x]])/f^2 + (d*x*Sech[e]*(f*x*Cosh[e] - 2*Sinh[e]))/(2*f) - (d
*x*Sech[e]*Sech[e + f*x]*Sinh[f*x])/f - (c*Tanh[e + f*x])/f

________________________________________________________________________________________

Maple [A]
time = 1.05, size = 65, normalized size = 1.62

method result size
risch \(\frac {d \,x^{2}}{2}+c x -\frac {2 d x}{f}-\frac {2 d e}{f^{2}}+\frac {2 d x +2 c}{f \left (1+{\mathrm e}^{2 f x +2 e}\right )}+\frac {d \ln \left (1+{\mathrm e}^{2 f x +2 e}\right )}{f^{2}}\) \(65\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((d*x+c)*tanh(f*x+e)^2,x,method=_RETURNVERBOSE)

[Out]

1/2*d*x^2+c*x-2*d*x/f-2*d/f^2*e+2*(d*x+c)/f/(1+exp(2*f*x+2*e))+d/f^2*ln(1+exp(2*f*x+2*e))

________________________________________________________________________________________

Maxima [B] Leaf count of result is larger than twice the leaf count of optimal. 136 vs. \(2 (40) = 80\).
time = 0.31, size = 136, normalized size = 3.40 \begin {gather*} c {\left (x + \frac {e}{f} - \frac {2}{f {\left (e^{\left (-2 \, f x - 2 \, e\right )} + 1\right )}}\right )} - \frac {1}{2} \, d {\left (\frac {2 \, x e^{\left (2 \, f x + 2 \, e\right )}}{f e^{\left (2 \, f x + 2 \, e\right )} + f} - \frac {f x^{2} + {\left (f x^{2} e^{\left (2 \, e\right )} - 2 \, x e^{\left (2 \, e\right )}\right )} e^{\left (2 \, f x\right )}}{f e^{\left (2 \, f x + 2 \, e\right )} + f} - \frac {2 \, \log \left ({\left (e^{\left (2 \, f x + 2 \, e\right )} + 1\right )} e^{\left (-2 \, e\right )}\right )}{f^{2}}\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((d*x+c)*tanh(f*x+e)^2,x, algorithm="maxima")

[Out]

c*(x + e/f - 2/(f*(e^(-2*f*x - 2*e) + 1))) - 1/2*d*(2*x*e^(2*f*x + 2*e)/(f*e^(2*f*x + 2*e) + f) - (f*x^2 + (f*
x^2*e^(2*e) - 2*x*e^(2*e))*e^(2*f*x))/(f*e^(2*f*x + 2*e) + f) - 2*log((e^(2*f*x + 2*e) + 1)*e^(-2*e))/f^2)

________________________________________________________________________________________

Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 277 vs. \(2 (40) = 80\).
time = 0.57, size = 277, normalized size = 6.92 \begin {gather*} \frac {d f^{2} x^{2} + 2 \, c f^{2} x + {\left (d f^{2} x^{2} + 2 \, {\left (c f^{2} - 2 \, d f\right )} x\right )} \cosh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right )^{2} + 2 \, {\left (d f^{2} x^{2} + 2 \, {\left (c f^{2} - 2 \, d f\right )} x\right )} \cosh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right ) \sinh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right ) + {\left (d f^{2} x^{2} + 2 \, {\left (c f^{2} - 2 \, d f\right )} x\right )} \sinh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right )^{2} + 4 \, c f + 2 \, {\left (d \cosh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right )^{2} + 2 \, d \cosh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right ) \sinh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right ) + d \sinh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right )^{2} + d\right )} \log \left (\frac {2 \, \cosh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right )}{\cosh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right ) - \sinh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right )}\right )}{2 \, {\left (f^{2} \cosh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right )^{2} + 2 \, f^{2} \cosh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right ) \sinh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right ) + f^{2} \sinh \left (f x + \cosh \left (1\right ) + \sinh \left (1\right )\right )^{2} + f^{2}\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((d*x+c)*tanh(f*x+e)^2,x, algorithm="fricas")

[Out]

1/2*(d*f^2*x^2 + 2*c*f^2*x + (d*f^2*x^2 + 2*(c*f^2 - 2*d*f)*x)*cosh(f*x + cosh(1) + sinh(1))^2 + 2*(d*f^2*x^2
+ 2*(c*f^2 - 2*d*f)*x)*cosh(f*x + cosh(1) + sinh(1))*sinh(f*x + cosh(1) + sinh(1)) + (d*f^2*x^2 + 2*(c*f^2 - 2
*d*f)*x)*sinh(f*x + cosh(1) + sinh(1))^2 + 4*c*f + 2*(d*cosh(f*x + cosh(1) + sinh(1))^2 + 2*d*cosh(f*x + cosh(
1) + sinh(1))*sinh(f*x + cosh(1) + sinh(1)) + d*sinh(f*x + cosh(1) + sinh(1))^2 + d)*log(2*cosh(f*x + cosh(1)
+ sinh(1))/(cosh(f*x + cosh(1) + sinh(1)) - sinh(f*x + cosh(1) + sinh(1)))))/(f^2*cosh(f*x + cosh(1) + sinh(1)
)^2 + 2*f^2*cosh(f*x + cosh(1) + sinh(1))*sinh(f*x + cosh(1) + sinh(1)) + f^2*sinh(f*x + cosh(1) + sinh(1))^2
+ f^2)

________________________________________________________________________________________

Sympy [A]
time = 0.09, size = 66, normalized size = 1.65 \begin {gather*} \begin {cases} c x - \frac {c \tanh {\left (e + f x \right )}}{f} + \frac {d x^{2}}{2} - \frac {d x \tanh {\left (e + f x \right )}}{f} + \frac {d x}{f} - \frac {d \log {\left (\tanh {\left (e + f x \right )} + 1 \right )}}{f^{2}} & \text {for}\: f \neq 0 \\\left (c x + \frac {d x^{2}}{2}\right ) \tanh ^{2}{\left (e \right )} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((d*x+c)*tanh(f*x+e)**2,x)

[Out]

Piecewise((c*x - c*tanh(e + f*x)/f + d*x**2/2 - d*x*tanh(e + f*x)/f + d*x/f - d*log(tanh(e + f*x) + 1)/f**2, N
e(f, 0)), ((c*x + d*x**2/2)*tanh(e)**2, True))

________________________________________________________________________________________

Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 127 vs. \(2 (38) = 76\).
time = 0.40, size = 127, normalized size = 3.18 \begin {gather*} \frac {d f^{2} x^{2} e^{\left (2 \, f x + 2 \, e\right )} + d f^{2} x^{2} + 2 \, c f^{2} x e^{\left (2 \, f x + 2 \, e\right )} + 2 \, c f^{2} x - 4 \, d f x e^{\left (2 \, f x + 2 \, e\right )} + 2 \, d e^{\left (2 \, f x + 2 \, e\right )} \log \left (e^{\left (2 \, f x + 2 \, e\right )} + 1\right ) + 4 \, c f + 2 \, d \log \left (e^{\left (2 \, f x + 2 \, e\right )} + 1\right )}{2 \, {\left (f^{2} e^{\left (2 \, f x + 2 \, e\right )} + f^{2}\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((d*x+c)*tanh(f*x+e)^2,x, algorithm="giac")

[Out]

1/2*(d*f^2*x^2*e^(2*f*x + 2*e) + d*f^2*x^2 + 2*c*f^2*x*e^(2*f*x + 2*e) + 2*c*f^2*x - 4*d*f*x*e^(2*f*x + 2*e) +
 2*d*e^(2*f*x + 2*e)*log(e^(2*f*x + 2*e) + 1) + 4*c*f + 2*d*log(e^(2*f*x + 2*e) + 1))/(f^2*e^(2*f*x + 2*e) + f
^2)

________________________________________________________________________________________

Mupad [B]
time = 0.09, size = 56, normalized size = 1.40 \begin {gather*} x\,\left (c+\frac {d}{f}\right )+\frac {d\,x^2}{2}-\frac {d\,\ln \left (\mathrm {tanh}\left (e+f\,x\right )+1\right )}{f^2}-\frac {c\,\mathrm {tanh}\left (e+f\,x\right )}{f}-\frac {d\,x\,\mathrm {tanh}\left (e+f\,x\right )}{f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tanh(e + f*x)^2*(c + d*x),x)

[Out]

x*(c + d/f) + (d*x^2)/2 - (d*log(tanh(e + f*x) + 1))/f^2 - (c*tanh(e + f*x))/f - (d*x*tanh(e + f*x))/f

________________________________________________________________________________________